<template>
<div class="orderItem-wrap" v-if="data">
    <div class="order-wrap" v-for="(item) in data" :key="item.id">
        <div class="order-header clearfix">
            <div class="l" @click="getStore(item.stores)">
                {{ item.stores.title }}
                <van-icon name="arrow" />
            </div>
            <div style="color: #ff976a" class="r">
                <!-- {{ item.status }} -->
                <span :class="item.status == 'Finish' ? '' : 'dn'">已完成</span>
                <span :class="item.status == 'Wait' ? '' : 'dn'">未付款</span>
                <span :class="item.status == 'Unpaid' ? '' : 'dn'">未支付</span>
                <span :class="item.status == 'Dispatch' ? '' : 'dn'">配送中</span>
                <span :class="item.status == 'Refund' ? '' : 'dn'">退款</span>
                <span :class="item.status == 'Paid' ? '' : 'dn'">待发货</span>
                <span></span>
            </div>
        </div>
        <div class="order-container clearfix">
            <div style="margin-bottom: 5px;">
                订单号: {{ item.order_sn }}
            </div>
            <van-row>
                <van-col span="6">
                    <van-image width="70" height="70" :src="item.params.avatar" />
                </van-col>
                <van-col span="12">
                    {{ item.params.title }}
                </van-col>
                <van-col offset="1" span="5" class="sepc"><span> ¥ {{ item.params.price }}</span>
                    <p style="text-align: right">×{{ item.params.number }}</p>
                </van-col>
            </van-row>
            <div class="r">
                合计: {{ item.price }}
            </div>
        </div>
        <div class="goods-address">
             <p :class="item.dispatch_info.str == 'xd0_123' ? 'dn' : ''">快递类型：{{ item.dispatch_info.str }}</p>
             <p :class="item.dispatch_info.str == 'xd0_123' ? 'dn' : ''">快递单号：{{ item.dispatch_info.num }}</p>
          </div>
        <div class="order-tool clearfix">
            <div class="l">
                <van-icon style="line-height: 30px" size="18px" @click="getdetail(item)" name="ellipsis" />
            </div>
            <div class="r">
                <van-button :class="item.status == 'Wait' ? '' : 'dn'" size="small" round type="info" @click="getChangestatus(item)">去付款</van-button>
                <van-button :class="item.status == 'Dispatch' ? '' : 'dn'" size="small" round type="info" color="#7232dd" @click="getChangestatus(item)">确认收货</van-button>
            </div>
        </div>
    </div>
</div>
</template>

<script>
export default {
    name: "OrderItem",
    props: {
        data: [Array, Object],
        dataListTitle: [Array, Object]
    },
    data() {
        return {
            list: null
        }
    },
    methods: {
        getChangestatus(item) {
            let data = [];
            switch (item.status) {
                case 'Wait':
                    this.$emit('getPayOrder', item)
                    break;
                case 'Refund':
                    break;
                case 'Unpaid':
                    break;

                case 'Dispatch':
                    this.$emit('getChangestatus',item)
                    break;

                case 'Paid':
                    break;

                case 'Finish':
                    this.$emit('getChangestatus', item)
                    break;

                default:
                    data.push('待付款')
                    break;
            }

        },
        getStore(store) {
            this.$emit('getStore', store)
        },
        getdetail(item) {
            this.$emit('getdetail', item)
        }
    }
};
</script>

<style lang="less" scoped>
.orderItem-wrap {
    .order-wrap {
        width: 100%;
        background-color: white;
        border-radius: 4px;
        padding: 4px 0;
        margin: 5px 0;

        .order-header {
            width: 100%;
            line-height: 30px;
            padding: 2px 12px;
            box-sizing: border-box;
        }
        .order-container {
            padding: 2px 12px;
            box-sizing: border-box;
        }
        .order-tool {
            padding: 2px 12px;
            box-sizing: border-box;
        }
    }
    .sepc {
        text-align: right
    }
    .goods-address p {
        margin: .2rem 0;
        padding: 0 7px;
    }
}
</style>
